﻿using ForgottenTalez.GameStateManager.ScreenMan;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace ForgottenTalez.Renderers
{
    class CardButtonRenderer: ButtonRenderer
    {
        Texture2D cardTexture;
        Vector2 origin;
        public CardButtonRenderer(ScreenManager ScreenManager, Texture2D CardTexture)
            : base(ScreenManager)
        {
            cardTexture = CardTexture;
            origin = new Vector2(CardTexture.Bounds.X / 2, CardTexture.Bounds.Y / 2); 
        }
        public override void Render(GameScreen screen, bool isSelected, GameTime gameTime, Vector2 Position, Vector2 Size)
        {
            if (isSelected)
            {
                screen.ScreenManager.SpriteBatch.Draw(cardTexture,
                     new Rectangle((int)Position.X, (int)Position.Y, (int)(Size.X * SHRINK_BY_SCALE), (int)(Size.Y * SHRINK_BY_SCALE)),
                     cardTexture.Bounds,
                     Color.White,
                     0,
                     origin * SHRINK_BY_SCALE,
                     SpriteEffects.None,
                     0);
            }
            else
            {
                screen.ScreenManager.SpriteBatch.Draw(cardTexture,
                    new Rectangle((int)Position.X, (int)Position.Y, (int)(Size.X), (int)(Size.Y)),
                    cardTexture.Bounds,
                    Color.White,
                    0,
                    origin,
                    SpriteEffects.None,
                    0);
            }
        }
    }
}
